package com.pan.admin.module.loanProduct.entity.vo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import lombok.Data;

@Data
public class LoanProductHistoryBillVO {

    private Long id;
    /**
     * 分组词
     */
    private String groupingWords;
    /**
     * 计划名称
     */
    private String displayName;
    /**
     * 计划类型
     */
    private String planType;
    /**
     * 主体名称
     */
    private String name;
    /**
     * 消耗总数
     */
    private Long total = 0L;
    /**
     * 结算单价
     */
    private BigDecimal price;
    /**
     * 分润价格
     */
    private BigDecimal share;
    /**
     * 消耗金额
     */
    private BigDecimal amount = BigDecimal.ZERO;
    /**
     * 充值
     */
    private BigDecimal recharge = BigDecimal.ZERO;
    /**
     * 补单
     */
    private BigDecimal supplement = BigDecimal.ZERO;
    /**
     * 利润
     */
    private BigDecimal profit = BigDecimal.ZERO;
    /**
     * 正常量
     */
    private Long normal = 0L;
    /**
     * 唤醒量
     */
    private Long wake = 0L;
    /**
     * 截止统计时间
     */
    private String dateTime;
    /**
     * 主体余额
     */
    private BigDecimal balance;
    /**
     * 主体结余
     */
    private BigDecimal accountBalance;
    /**
     * 主体id
     */
    private Long loanProductId;
    /**
     * 主体计划id
     */
    private Long loanProductPlayId;
    private List<LoanProductHistoryBillVO> children;

    public void addRecharge(BigDecimal recharge) {
        if (this.recharge == null) {
            this.recharge = BigDecimal.ZERO;
        }
        if (recharge == null) {
            recharge = BigDecimal.ZERO;
        }
        this.recharge = this.recharge.add(recharge);
    }

    public void addSupplement(BigDecimal supplement) {
        if (this.supplement == null) {
            this.supplement = BigDecimal.ZERO;
        }
        if (supplement == null) {
            supplement = BigDecimal.ZERO;
        }
        this.supplement = this.supplement.add(supplement);
    }

    public void addProfit(BigDecimal profit) {
        if (this.profit == null) {
            this.profit = BigDecimal.ZERO;
        }
        if (profit == null) {
            profit = BigDecimal.ZERO;
        }
        this.profit = this.profit.add(profit);
    }

    public void addBalance(BigDecimal balance) {
        Objects.requireNonNull(balance);
        if (this.balance == null) {
            this.balance = BigDecimal.ZERO;
        }
        this.balance = this.balance.add(balance);
    }

    public void addAccountBalance(BigDecimal accountBalance) {
        if (this.accountBalance == null) {
            this.accountBalance = BigDecimal.ZERO;
        }
        if (accountBalance == null) {
            accountBalance = BigDecimal.ZERO;
        }
        this.accountBalance = this.accountBalance.add(accountBalance);
    }

    public void addTotal(Long total) {
        if (this.total == null) {
            this.total = Long.valueOf(0L);
        }
        this.total += total;
    }

    public void addAmount(BigDecimal amount) {
        Objects.requireNonNull(amount);
        if (this.amount == null) {
            this.amount = BigDecimal.ZERO;
        }
        this.amount = this.amount.add(amount);
    }

    public void addNormal(Long normal) {
        if (this.normal == null) {
            this.normal = Long.valueOf(0L);
        }
        this.normal += normal;
    }

    public void addWake(Long wake) {
        if (this.wake == null) {
            this.wake = Long.valueOf(0L);
        }
        this.wake += wake;
    }
}
